package com.medical.admin.sys.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.medical.admin.sys.common.dto.BatchDto;
import com.medical.admin.sys.entity.Admin;

import java.util.List;


/*
 * @Date : 2024/4/27 下午1:28
 * @Created by Lang
 * @ProjectName : medical-appointment-registration
 */

public interface AdminMapper extends BaseMapper<Admin> {
    default Admin selectByUsername(String marAdminUsername) {
        LambdaQueryWrapper<Admin> eq = new QueryWrapper<Admin>()
                .lambda()
                .eq(Admin::getMarAdminUsername, marAdminUsername);
        return this.selectOne(eq);
    }

    default Admin selectByAccount(String marAdminAccount) {
        LambdaQueryWrapper<Admin> eq = new QueryWrapper<Admin>()
                .lambda()
                .eq(Admin::getMarAdminAccount, marAdminAccount);
        return this.selectOne(eq);
    }

    default Integer delBatch(List<Long> adminIds){
        LambdaUpdateWrapper<Admin> in = new UpdateWrapper<Admin>().lambda().set(Admin::getMarAdminStatus, 0).in(Admin::getMarAdminId, adminIds);
        return this.update(in);
    }
}